<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>确认订单</title>
    <link rel="stylesheet" type="text/css" href="../../../css/index.css" />
    <style>

       	.address-list{width: 100%;}
		.address-list .address-one{width: 100%;background: #ffffff;padding: 0 15px;box-sizing: border-box;margin-bottom: 10px;}
		.address-list .address-one .top-box{align-items: center;font-size: 15px;color: #333333;padding-top: 10px;box-sizing: border-box;}
		.address-list .address-one .top-box .name{font-weight: 700;}
		.address-list .address-one .top-box .phone{padding-left:10px;box-sizing: border-box;font-weight: 700;}
    	.address-list .address-one .top-box .moren{padding-left: 8px;font-size: 12px;color: #FF9502;display: none;}
    	.address-list .address-one .content{font-size: 14px;color: #646466;word-break: break-all;padding: 6px 0 10px 0;box-sizing: border-box;}
    	.address-list .address-one .bot-box{height: 54px;align-items: center;font-size: 12px;}
    	.address-list .address-one .bot-box .moren-btn{padding-left: 26px;box-sizing: border-box;background: url(../../../image/main2/sel_icon0.png) no-repeat left center;background-size:16px;}
    	.address-list .address-one .bot-box .del{height: 54px;margin-left: 15px;padding-left: 20px;box-sizing: border-box;background: url(../../../image/main3/addr_icon2.png) no-repeat left center;
        background-size:14px;line-height: 54px;}
    	.address-list .address-one .bot-box .edit{height: 54px;margin-right:15px;padding-left: 20px;box-sizing: border-box;background: url(../../../image/main3/addr_icon1.png) no-repeat left center;background-size:14px;line-height: 54px;}
        .address-list .address-one .bot-box .fg{height: 14px;width:1px;}
    	.address-list .address-one.on .bot-box .moren-btn{background: url(../../../image/main2/sel_icon1.png) no-repeat left center;background-size:16px;}
    	.address-list .address-one.on .top-box .moren{padding-left: 8px;font-size: 12px;color: #FF9502;display: block;}

    </style>
</head>

<body>
    <div id="vue">

    	<div class="address-list" style="display:none;" :style="{ display:(Pdata ? '':'none')}">
    		<div class="address-one" :class="['address-one',item.default == 1 ? 'on' : '']" v-for="(item,key) in Pdata.listData" :data-id="item.id">
    			<div class="top-box flex">
                    <div class="name" v-text="item.uname"></div>
    				<div class="phone" v-text="item.phone"></div>
    			</div>
    			<div class="content" v-text="item.qustr + item.address"></div>
    			<div class="bot-box flex border-top">
    				<div :class="['moren-btn flex1',item.default == 1 ? 'on' : '']" tapmode onclick="editDefClick(this)" :data-id="item.id">默认地址</div>
    				<div class="edit flex" tapmode onclick="editClick(this);" :data-index="key" :data-id="item.id">编辑</div>
                    <div class="fg border-left"></div>
    				<div class="del flex" tapmode onclick="delClick(this);" :data-id="item.id">删除</div>
    			</div>
    		</div>
    	</div>

        <!--占位图-->
        <div class="nodata" style="display:none;" :style="{ display:(noData ? '':'none')}">
            <img src="../../../image/no_page/no_dizhi.png" />
            <p>暂无地址</p>
        </div>
        <!-- 底部 -->
        <div class="bottom-box" :style="{ display:(loadingMsg ? '':'none')}">
            <div class="msgbox" v-html="loadingMsg" style="color:#999;"></div>
        </div>

    	<!--底部的立即分享按钮-->
		<div class="warp-btn" id="app-footer" tapdome onclick="addAddress()">
            <div class="btn">新建地址</div>
        </div>
    </div>

<script type="text/javascript" src="../../../script/base.min.js" id="loadjs" data-load=""></script>
<script type="text/javascript">

	define(function (require, exports, module) {
        lanYun.setFooter('app-footer');

	    getData = function(loading) {
	        lanYun.getVueData({url:'address/index',get:{page:lanYun.page},cache:true,loading:loading}, function(ret){
                //console.log(JSON.stringify(ret));
	        });
	    };
	    lanYun.newVue('#vue', function() {
	        getData(2);
	    });

	    //滚动加载..
		new auiScroll({distance:200, listen:true},function(ret) {
			if($(window).scrollTop() < 2) ret.isToBottom = false;
			if(!ret.isToBottom) return;
			getData(0);
		});

	    //============================
        onShow = function () {
			var reshpage = lanYun.getStorage('reshpage');
			if(reshpage){
				lanYun.rmStorage('reshpage');
                lanYun.ajaxPageSta = 0; lanYun.page = 1;
				getData(2);
			}
		}

	    //修改地址
	    editClick = function(tis){
	        var dst = tis.dataset;
            var data = lanYun.vue.Pdata.listData[dst.index];
            //console.log(JSON.stringify(data));
	        lanYun.openWin('user/address/add.html', {
	            title : '编辑地址',
	            frameParam : {id:data.id,quid:data.quid,qustr:data.qustr,uname:data.uname,phone:data.phone,address:data.address,default:data.default,type:"edit"},
	        });
	    };

        //删除地址
        delClick = function (tis){
			var dst = tis.dataset;
			lanYun.alert({fname:'diaLogBox1',title:'提示', button:['取消','确定'],content: '您确定要删除地址吗？'},function(ret){
	            if (ret.index == 0) return;
                lanYun.get('address/del?id='+ dst.id,function (ret) {
                    lanYun.toast(ret.msg);
                    if(ret.errcode == 0){
                        lanYun.page = 1;lanYun.ajaxPageSta = 0;
        	            getData(2);
                    }
                })
	        });
		}

	    //新增地址
	    addAddress = function(tis){
	        lanYun.openWin('user/address/add.html', {
	            title : '添加收货地址',
	            frameParam : {type:'add'},
	        });
	    };

	    //选择为默认
	    editDefClick = function (tis) {
            if($(tis).hasClass('on')){
                return;
            }
	        lanYun.post('address/setdef', {id:tis.dataset.id} ,function (ret) {
	            if(ret.errcode>0) {
	                lanYun.toast(ret.msg);
	            }
			    lanYun.page = 1;lanYun.ajaxPageSta = 0;
	            getData(2);
	        },2);
	    };

	});
</script>
</body>
</html>
